﻿Imports System.ComponentModel
Imports DTO
Imports System.Data.SqlClient

Public Class ChucNangDAO

    Shared Function layChucNang(maNhom As String) As DataTable
        Dim valList As New List(Of SqlParameter)
        Dim para As SqlParameter
        para = New SqlParameter("@MaNhom", SqlDbType.VarChar, 6)
        para.Direction = ParameterDirection.Input
        para.Value = maNhom
        valList.Add(para)
        Return CKetNoi.ThucThiStoreCoThamSo("usp_LayBangPhanQuyem", valList)
    End Function

    Shared Function layQuyenCuaND(maND As String, MaCN As Integer) As PhanQuyenNhonNDDTO
        Dim pq As New PhanQuyenNhonNDDTO
        Dim cn As SqlConnection = CKetNoi.Connect
        Dim cmd As New SqlCommand
        cmd.Connection = cn
        cmd.CommandText = "usp_LayThongTinPhanQuyen"
        cmd.CommandType = CommandType.StoredProcedure

        Dim para As SqlParameter
        para = New SqlParameter("@MaND", SqlDbType.VarChar, 7)
        para.Direction = ParameterDirection.Input
        para.Value = maND
        cmd.Parameters.Add(para)

        para = New SqlParameter("@MaCN", SqlDbType.Int)
        para.Direction = ParameterDirection.Input
        para.Value = MaCN
        cmd.Parameters.Add(para)
        cn.Open
        Dim reader As SqlDataReader = cmd.ExecuteReader
        While reader.Read
            pq.MaChucNang = reader("MaChucNang")
            pq.TatCa = reader("TatCa")
            pq.TruyCap = reader("TruyCap")
            pq.Them = reader("Them")
            pq.Xoa = reader("Xoa")
            pq.Sua = reader("Sua")
            pq.InPQ = reader("In")
            pq.Nhap = reader("Nhap")
        End While
        cn.Close
        Return pq
    End Function

End Class
